# 检查sku规格数据是否有效
# spu_specs = spu.specs.all()  # 当前商品的所有规格选项  例如: 颜色 内存 屏幕大小
# spec_count = spu_specs.count()
# specs = attrs['specs']   #  用户输入的规格选项

# # SKU商品的规格数据是否完整
# if spec_count > len(specs):
#     raise serializers.ValidationError('SKU规格数据不完整')
#
# # SKU商品的规格数据是否一致
# spu_specs_ids = [spec.id for spec in spu_specs]  # 每一个规格的id 如：颜色 为黑色 13  红色 14
# specs_ids = [spec.get('spec_id') for spec in specs] #
#
# if spu_specs_ids.sort() != specs_ids.sort():
#     raise serializers.ValidationError('商品规格数据有误')
#
# for spec in specs:
#     spec_id = spec.get('spec_id')
#     option_id = spec.get('option_id')  # 选项
#
#     # 检查spec_id对应的规格是否包含option_id对应的选项
#     options = SpecificationOption.objects.filter(spec_id=spec_id)
#     options_ids = [option.id for option in options]
#
#     if option_id not in options_ids:
#         raise serializers.ValidationError('规格选项数据有误')
#
# return attrs
